﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Finbook.GameApp.Models.V6
{
    public class PlayerV6
        : RoleV6
    {
        public PlayerV6(int hp,string name)
            : base(hp,name)
        { }

        public override void BeHit(SkillV6 skill, RoleV6 from)
        {
            base.BeHit(skill, from);
            if (HP*1.0f/MaxHP<=0.5f)
            {
                Skills.ForEach(s => s.Multiply = 2);
                CommonConsole.WriteLine($"{Name}:\t愤怒，攻击大大增加", ConsoleColor.Yellow);
            }
        }

        public override SkillV6 SelectSkill()
        {
            var bSuccess = false;
            var index = 0;
            while (!bSuccess)
            {
                Console.WriteLine($"请选择您的技能{1}~{Skills.Count}");
                var input = Console.ReadLine();
                if (!string.IsNullOrEmpty(input))
                {
                    if (int.TryParse(input, out index))
                    {
                        if (index>0&&index<=Skills.Count)
                        {
                            bSuccess = true;
                        }
                        else
                        {
                            bSuccess = false;
                        }
                    }
                    else
                    {
                        bSuccess = false;
                    }
                }
                else
                {
                    bSuccess = false;
                }
            }
            return Skills[index - 1];
        }
    }
}
